<template>
  <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="card">
      <el-row :gutter="20" class="ipn_reo">
        <el-col :span="8">
          <el-input
            placeholder="请输入搜索内容"
            class="input-with-select"
            v-model="queryInfo.query"
            clearable
            @clear="getOrdersList()"
          >
            <el-button
              slot="append"
              icon="el-icon-search"
              @click="getOrdersList()"
            >
            </el-button>
          </el-input>
        </el-col>
        <el-col :span="4">
          
        </el-col>
      </el-row>
      <el-table :data="ordersList" stripe border>
        <el-table-column type="index" label="#"> </el-table-column>
        <el-table-column prop="order_number" label="订单编号"> </el-table-column>
        <el-table-column prop="order_price" label="订单价格" width="80px"> </el-table-column>
        <el-table-column prop="pay_status" label="是否付款" width="80px">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.pay_status==='1'" type="success">已付款</el-tag>
            <el-tag v-else type="danger">未付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货" width="80px"> </el-table-column>
        <el-table-column prop="create_time" label="下单时间" width="100px"> </el-table-column>
        <el-table-column  label="操作" width="120px">
          <template slot-scope="scope">
            <el-button type="primary" icon="el-icon-edit" size="small"></el-button>
            <el-button
            size="small"
              type="success"
              icon="el-icon-location-outline"
              @click="removeRolesById(scope.row.id)"
              ></el-button
            >
            </template
          >
        </el-table-column>
      </el-table>
      <!-- 分页区域 -->
      <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="queryInfo.pagenum"
      :page-sizes="[1, 2, 5, 10]"
      :page-size="queryInfo.pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
    </el-card>
  </div>
</template>

<script>
import {
  getOrders,
} from "@/api/orders";
export default {
  data() {
    return {
      total: 0,
      ordersList: [],
      addDialogVisible: false,
    
      queryInfo: {
        query: "",
        pagenum: 1,
        pagesize: 10,
      },
    };
  },
  created() {
    this.getOrdersList();
  },
  methods: {
   
    // 获取数据
    async getOrdersList() {
      const res = await getOrders(this.queryInfo);
      // console.log(res);
      if (res.meta.status !== 200) {
        return this.$message.error("获取角色列表失败");
      }
      this.ordersList = res.data.goods;
      // console.log(res);
      this.total = res.data.total;
      // console.log(this.ordersList);
    },
    handleSizeChange(newSize) {
      // console.log("newSize",newSize);
      this.queryInfo.pagesize = newSize;
      this.getOrdersList();
    },
    handleCurrentChange(newPage) {
      // console.log("newPage",newPage);
      this.queryInfo.pagenum = newPage;
      this.getOrdersList();
    },
  },
};
</script>

<style>
.butt_tian {
  margin-bottom: 15px;
}
.ipn_reo{
   margin-bottom: 15px;
}
</style>